(function(window, angular, undefined){
	angular.module('arcgis.draw', [])
	.factory('$arcgis_draw',  ["$rootScope", function($rootScope) {
		$arcgis_draw = {
			
			// gisObject.drawToolbars 需要绘制工具条参数

			/* 
			 * 开始绘制点
			 */
			drawPoint : function(onDrawEnd){
				var go = $rootScope.gisObject;
				var handler = dojo.connect(go.drawToolbars, "onDrawEnd", function(geometry){
					dojo.disconnect(handler);
					if(onDrawEnd) onDrawEnd(geometry);
				});
				$rootScope.mapPan();
				if(!$rootScope.isNullOrUndefined(go.map)){
					go.map.setMapCursor("url("+getBasePath()+"/arcgis/images/cur/crosshair.cur),auto");
				}
				if(!$rootScope.isNullOrUndefined(go.drawToolbars)){
					go.drawToolbars.activate(esri.toolbars.Draw['POINT']);
				}
			},

			/* 
			 * 开始绘制多点
			 */
			drawMultiPoint : function(onDrawEnd){ 
				var go = $rootScope.gisObject;
				var handler = dojo.connect(go.drawToolbars, "onDrawEnd", function(geometry){
					dojo.disconnect(handler);
					if(onDrawEnd) onDrawEnd(geometry);
				});
				$rootScope.mapPan();
				if(!$rootScope.isNullOrUndefined(go.map)){
					go.map.setMapCursor("url("+getBasePath()+"/arcgis/images/cur/crosshair.cur),auto");
				}
				if(!$rootScope.isNullOrUndefined(go.drawToolbars)){
					go.drawToolbars.activate(esri.toolbars.Draw['MULTIPOINT']);
				}
			},

			/* 
			 * 开始绘制线段
			 */
			drawLine : function(onDrawEnd){ 
				var go = $rootScope.gisObject;
				var handler = dojo.connect(go.drawToolbars, "onDrawEnd", function(geometry){
					dojo.disconnect(handler);
					if(onDrawEnd) onDrawEnd(geometry);
				});
				$rootScope.mapPan();
				if(!$rootScope.isNullOrUndefined(go.map)){
					go.map.setMapCursor("url("+getBasePath()+"/arcgis/images/cur/crosshair.cur),auto");
				}
				if(!$rootScope.isNullOrUndefined(go.drawToolbars)){
					go.drawToolbars.activate(esri.toolbars.Draw['LINE']);
				}
			},

			/* 
			 * 开始绘制线
			 */
			drawPolyline : function(onDrawEnd){ 
				var go = $rootScope.gisObject;
				var handler = dojo.connect(go.drawToolbars, "onDrawEnd", function(geometry){
					dojo.disconnect(handler);
					if(onDrawEnd) onDrawEnd(geometry);
				});
				$rootScope.mapPan();
				if(!$rootScope.isNullOrUndefined(go.map)){
					go.map.setMapCursor("url("+getBasePath()+"/arcgis/images/cur/crosshair.cur),auto");
				}
				if(!$rootScope.isNullOrUndefined(go.drawToolbars)){
					go.drawToolbars.activate(esri.toolbars.Draw['POLYLINE']);
				}
			},

			/* 
			 * 开始绘制自由线
			 */
			drawFreehandPolyline : function(onDrawEnd){ 
				var go = $rootScope.gisObject;
				var handler = dojo.connect(go.drawToolbars, "onDrawEnd", function(geometry){
					dojo.disconnect(handler);
					if(onDrawEnd) onDrawEnd(geometry);
				});
				$rootScope.mapPan();
				if(!$rootScope.isNullOrUndefined(go.map)){
					go.map.setMapCursor("url("+getBasePath()+"/arcgis/images/cur/crosshair.cur),auto");
				}
				if(!$rootScope.isNullOrUndefined(go.drawToolbars)){
					go.drawToolbars.activate(esri.toolbars.Draw['FREEHANDPOLYLINE']);
				}
			},

			/* 
			 * 开始绘制面
			 */
			drawPolygon : function(onDrawEnd){ 
				var go = $rootScope.gisObject;
				var handler = dojo.connect(go.drawToolbars, "onDrawEnd", function(geometry){
					dojo.disconnect(handler);
					if(onDrawEnd) onDrawEnd(geometry);
				});
				$rootScope.mapPan();
				if(!$rootScope.isNullOrUndefined(go.map)){
					go.map.setMapCursor("url("+getBasePath()+"/arcgis/images/cur/crosshair.cur),auto");
				}
				if(!$rootScope.isNullOrUndefined(go.drawToolbars)){
					go.drawToolbars.activate(esri.toolbars.Draw['POLYGON']);
				}
			},

			/* 
			 * 开始绘制自由面
			 */
			drawFreehandPolygon : function(onDrawEnd){ 
				var go = $rootScope.gisObject;
				var handler = dojo.connect(go.drawToolbars, "onDrawEnd", function(geometry){
					dojo.disconnect(handler);
					if(onDrawEnd) onDrawEnd(geometry);
				});
				$rootScope.mapPan();
				if(!$rootScope.isNullOrUndefined(go.map)){
					go.map.setMapCursor("url("+getBasePath()+"/arcgis/images/cur/crosshair.cur),auto");
				}
				if(!$rootScope.isNullOrUndefined(go.drawToolbars)){
					go.drawToolbars.activate(esri.toolbars.Draw['FREEHANDPOLYGON']);
				}
			},

			/* 
			 * 开始绘制箭头
			 */
			drawArrow : function(onDrawEnd){ 
				var go = $rootScope.gisObject;
				var handler = dojo.connect(go.drawToolbars, "onDrawEnd", function(geometry){
					dojo.disconnect(handler);
					if(onDrawEnd) onDrawEnd(geometry);
				});
				$rootScope.mapPan();
				if(!$rootScope.isNullOrUndefined(go.map)){
					go.map.setMapCursor("url("+getBasePath()+"/arcgis/images/cur/crosshair.cur),auto");
				}
				if(!$rootScope.isNullOrUndefined(go.drawToolbars)){
					go.drawToolbars.activate(esri.toolbars.Draw['ARROW']);
				}
			},

			/* 
			 * 开始绘制三角形
			 */
			drawTriangle : function(onDrawEnd){
				var go = $rootScope.gisObject;
				var handler = dojo.connect(go.drawToolbars, "onDrawEnd", function(geometry){
					dojo.disconnect(handler);
					if(onDrawEnd) onDrawEnd(geometry);
				});
				$rootScope.mapPan(); 
				if(!$rootScope.isNullOrUndefined(go.map)){
					go.map.setMapCursor("url("+getBasePath()+"/arcgis/images/cur/crosshair.cur),auto");
				}
				if(!$rootScope.isNullOrUndefined(go.drawToolbars)){
					go.drawToolbars.activate(esri.toolbars.Draw['TRIANGLE']);
				}
			},

			/* 
			 * 开始绘制圆形
			 */
			drawCircle : function(onDrawEnd){ 
				var go = $rootScope.gisObject;
				var handler = dojo.connect(go.drawToolbars, "onDrawEnd", function(geometry){
					dojo.disconnect(handler);
					if(onDrawEnd) onDrawEnd(geometry);
				});
				$rootScope.mapPan();
				if(!$rootScope.isNullOrUndefined(go.map)){
					go.map.setMapCursor("url("+getBasePath()+"/arcgis/images/cur/crosshair.cur),auto");
				}
				if(!$rootScope.isNullOrUndefined(go.drawToolbars)){
					go.drawToolbars.activate(esri.toolbars.Draw['CIRCLE']);
				}
			},
			
			/* 
			 * 开始绘制椭圆
			 */
			drawEllipse : function(onDrawEnd){ 
				var go = $rootScope.gisObject;
				var handler = dojo.connect(go.drawToolbars, "onDrawEnd", function(geometry){
					dojo.disconnect(handler);
					if(onDrawEnd) onDrawEnd(geometry);
				});
				$rootScope.mapPan();
				if(!$rootScope.isNullOrUndefined(go.map)){
					go.map.setMapCursor("url("+getBasePath()+"/arcgis/images/cur/crosshair.cur),auto");
				}
				if(!$rootScope.isNullOrUndefined(go.drawToolbars)){
					go.drawToolbars.activate(esri.toolbars.Draw['ELLIPSE']);
				}
			},

			/* 
			 * 开始绘制Extent
			 */
			drawExtent : function(onDrawEnd){ 
				var go = $rootScope.gisObject;
				var handler = dojo.connect(go.drawToolbars, "onDrawEnd", function(geometry){
					dojo.disconnect(handler);
					if(onDrawEnd) onDrawEnd(geometry);
				});
				$rootScope.mapPan();
				if(!$rootScope.isNullOrUndefined(go.map)){
					go.map.setMapCursor("url("+getBasePath()+"/arcgis/images/cur/crosshair.cur),auto");
				}
				if(!$rootScope.isNullOrUndefined(go.drawToolbars)){
					go.drawToolbars.activate(esri.toolbars.Draw['EXTENT']);
				}
			},

			/* 
			 * 结束绘制
			 */
			deDraw : function(){ 
				var go = $rootScope.gisObject;
				$rootScope.mapPan();
				if(!$rootScope.isNullOrUndefined(go.drawToolbars)){
					go.drawToolbars.deactivate();
				}
			},

			/* 
			 * 结束绘制并清除绘制结果
			 */
			deDrawAndClearGraphics : function(){ 
				var go = $rootScope.gisObject;
				$rootScope.deDraw();
				$rootScope.clearGraphics();
				if(go.map
					&& go.map.infoWindow){
					go.map.infoWindow.hide();
				}
			}
		};
		for(f in $arcgis_draw){
			$rootScope[f] = $arcgis_draw[f];
		}
		return $arcgis_draw;
	}])
	.run(["$rootScope", "$arcgis_draw", function($rootScope, $arcgis_draw) {}]);
}(window, angular));
(function(window, angular, undefined){
	angular.module('arcgis.geometryservice', [])
	.factory('$arcgis_geometryservice', ["$rootScope", function($rootScope) {
		$arcgis_geometryservice = {

			// 需要提供gisObject.geometryService空间分析服务参数

			/* 
			 * 进行投影转换
			 * onProjectComplete(graphics){
			 */
			geoProject : function(geometrys, outSR, onProjectComplete){
				var go = $rootScope.gisObject;
				// 进行投影转换，完成后调用projectComplete
				var handler = dojo.connect(go.geometryService, "onProjectComplete", function(result){
					dojo.disconnect(handler);
					if(onProjectComplete) onProjectComplete(result);
				});
			    var params = new esri.tasks.ProjectParameters();
				params.geometries = geometrys;
				params.outSR = outSR;
				go.geometryService.project(params);
			}, 

			/* 
			 * 长度计算
			 */
			geoLengths : function(geometrys,onLengthsComplete){
				var go = $rootScope.gisObject;
				var handler = dojo.connect(go.geometryService, "onLengthsComplete", function(result){
					dojo.disconnect(handler);
					if(onLengthsComplete) onLengthsComplete(result);
				});
				var lengthParams = new esri.tasks.LengthsParameters();
				lengthParams.polylines = geometrys;
				lengthParams.lengthUnit = esri.tasks.GeometryService.UNIT_KILOMETER;
		     	go.geometryService.lengths(lengthParams);
			}, 

			/* 
			 * 长度面积计算
			 */
			geoAreasAndLengths : function(geometrys,onAreasAndLengthsComplete){
				var go = $rootScope.gisObject;
				var handler = dojo.connect(go.geometryService, "onAreasAndLengthsComplete", function(result){
					dojo.disconnect(handler);
					if(onAreasAndLengthsComplete) onAreasAndLengthsComplete(result);
				});
				var areasAndLengthParams = new esri.tasks.AreasAndLengthsParameters();
				areasAndLengthParams.areaUnit = esri.tasks.GeometryService.UNIT_SQUARE_KILOMETERS;
				areasAndLengthParams.polygons = geometrys;
				// 进行面积测量
				go.geometryService.areasAndLengths(areasAndLengthParams);
			}, 

			/* 
			 * 简单化处理
			 * onSimplifyComplete(graphics)
			 */
			geoSimplify : function(geometrys,onSimplifyComplete){
				var go = $rootScope.gisObject;
				var handler = dojo.connect(go.geometryService, "onSimplifyComplete", function(result){
					dojo.disconnect(handler);
					if(onSimplifyComplete) onSimplifyComplete(result);
				});
		     	go.geometryService.simplify(geometrys);
			},

			/* 
			 * 简单化处理
			 */
			geoBuffer : function(distances, graphics, onBufferComplete){
				var go = $rootScope.gisObject;
				var handler = dojo.connect(go.geometryService, "onBufferComplete", function(result){
					dojo.disconnect(handler);
					if(onBufferComplete) onBufferComplete(result);
				});
				var params = new esri.tasks.BufferParameters();
				params.distances = distances;
				// 做缓存，都使用投影坐标
				params.outSpatialReference = go.tywkid;
				params.bufferSpatialReference = go.tywkid;
				params.geometries = graphics;
				//buffer的单位，米
   				params.unit = esri.tasks.BufferParameters.UNIT_METER;
				go.geometryService.buffer(params);
			},

			/* 
			 * 根据当前地图的投影情况，获取当前地图投影下的geometry长度
			 */
			getGeometryLength : function(mapGeometrys, onLengths){
				var go = $rootScope.gisObject;
				// 如果是地理坐标系统，则先转换为投影坐标
			    if(go.mapisdlwkid){
			    	$rootScope.geoProject(mapGeometrys, go.tywkid,
			    		function(graphics){
							$rootScope.geoLengths(graphics, onLengths);
						}
					);
			    }else{
			    	$rootScope.geoLengths(mapGeometrys, onLengths);
			    }
			},

			/* 
			 * 根据当前地图的投影情况，获取当前地图投影下的geometry面积
			 */
			getGeometryArea : function(mapGeometrys, onAreas){
				var go = $rootScope.gisObject;
				// 如果是地理坐标系统，则先转换为投影坐标
			    if(go.mapisdlwkid){
			    	$rootScope.geoProject(mapGeometrys, go.tywkid,
			    		function(graphics){
							// 如果为面类型需要先进行simplify操作在进行面积测算
					    	$rootScope.geoSimplify(graphics,function(graphics){
								// 进行面积测量
								$rootScope.geoAreasAndLengths(graphics, onAreas);
							});
						}
					);
			    }else{
			    	// 如果为面类型需要先进行simplify操作在进行面积测算
				    $rootScope.geoSimplify(mapGeometrys, function(graphics){
						// 进行面积测量
						$rootScope.geoAreasAndLengths(graphics, onAreas);
					});
			    }
			},

			/* 
			 * 根据当前地图的投影情况，对图形做buffer
			 */
			getBufferGeometry : function(geometrys, distances, onBuffer){
				if(distances<=0){
					onBuffer(geometrys);
					return;
				}

				var go = $rootScope.gisObject;
				// 完成缓冲处理
				var onBufferComplete = function (geometries) {
					if(go.mapisdlwkid){
						// 如果是地理坐标，需要将投影转换为地理
						$rootScope.geoProject(geometries, go.dlwkid,
							function(graphics){
								onBuffer(graphics);
							}
						);
					}else{
						onBuffer(geometries);
					}
				};

				// 缓冲前处理
				var optionBuffer = function(gm){
					var go = $rootScope.gisObject;
					// 如果为地理坐标，则先转换平面，再做缓存
					if(go.mapisdlwkid){
						$rootScope.geoProject(gm, go.tywkid,
							function(graphics){
								$rootScope.geoBuffer([distances],graphics,function(geometries){
									onBufferComplete(geometries);
								});
							}
						);
					}else{
						$rootScope.geoBuffer([distances],gm,function(geometries){
							onBufferComplete(geometries);
						});
					}
				}

				if(geometrys[0].type == "polygon"){
					// 如果为面，则先简单化
					$rootScope.geoSimplify(geometrys,
						function(spr){
							optionBuffer(spr);
						}
					);
				} else {
					optionBuffer(geometrys);
				}
			}
		};
		for(f in $arcgis_geometryservice){
			$rootScope[f] = $arcgis_geometryservice[f];
		}
		return $arcgis_geometryservice;
	}]).run(["$rootScope", "$arcgis_geometryservice", function($rootScope, $arcgis_geometryservice) { }]);
}(window, angular));
(function(window, angular, undefined){
	angular.module('arcgis.graphic', [])
	.factory('$arcgis_graphic', ["$rootScope", function($rootScope) {
		$arcgis_graphic = {

			styleConfig : {drawStyle:null,highLightDefaultStyle:null,highLightSelectStyle:null},

			// 创建Color对象
			createColorFromHex : function(hexCode) {
			  	if(hexCode.length==4) {
			    	var shortHexCode = hexCode; 
			    	var hexCode = '#';
			    	for(var i=1;i<4;i++) { 
			        	hexCode += (shortHexCode.charAt(i) + 
						shortHexCode.charAt(i)); 
			    	}
			  	}
			   	if ( hexCode.indexOf('#') == 0 ) {
			       	hexCode = hexCode.substring(1);
			   	}
			   	var red   = hexCode.substring(0,2);
			   	var green = hexCode.substring(2,4);
			   	var blue  = hexCode.substring(4,6);
			   	var rgb = { r: parseInt(red,16), g : parseInt(green,16), b : parseInt(blue,16) };
			   	return rgb;
			},

			// 普通绘制样式
			getDrawStyle : function(){
				if($rootScope.styleConfig.drawStyle){
					return $rootScope.styleConfig.drawStyle;
				}

				var drawStyle = {
					fillColor : $rootScope.createColorFromHex("#ff0000"),
					fillOpacity : 0.8,
					strokeColor : $rootScope.createColorFromHex("#ff0000"),
					strokeWidth : 2
				};
				$rootScope.styleConfig.drawStyle = drawStyle;
				return drawStyle;
			},

			// 高亮默认样式
			getHighLightDefaultStyle : function(){
				if($rootScope.styleConfig.highLightDefaultStyle){
					return $rootScope.styleConfig.highLightDefaultStyle;
				}

				var highLightDefaultStyle = {
					fillColor : $rootScope.createColorFromHex("#FBDF55"),
					fillOpacity : 0.5,
					strokeColor : $rootScope.createColorFromHex("#666666"),
					strokeWidth : 4
				};
				$rootScope.styleConfig.highLightDefaultStyle = highLightDefaultStyle;
				return highLightDefaultStyle;
			},

			// 高亮选择样式
			getHighLightSelectStyle : function(){
				if($rootScope.styleConfig.highLightSelectStyle){
					return $rootScope.styleConfig.highLightSelectStyle;
				}

				var highLightSelectStyle = {
					fillColor : $rootScope.createColorFromHex("#FA8650"),
					fillOpacity : 0.8,
					strokeColor : $rootScope.createColorFromHex("#3399ff"),
					strokeWidth : 4
				};
				$rootScope.styleConfig.highLightSelectStyle = highLightSelectStyle;
				return highLightSelectStyle;
			},

			/* 
			 * 获取点样式
			 */
			getDrawPointSymbol : function(){ 
				// 点样式
				var pointSymbol = new esri.symbol.SimpleMarkerSymbol(
					esri.symbol.SimpleMarkerSymbol.STYLE_SQUARE, 10,
					new esri.symbol.SimpleLineSymbol(
							esri.symbol.SimpleLineSymbol.STYLE_SOLID,
							new dojo.Color([
								$rootScope.getDrawStyle().strokeColor.r,
								$rootScope.getDrawStyle().strokeColor.g,
								$rootScope.getDrawStyle().strokeColor.b]), 1),
					new dojo.Color([$rootScope.getDrawStyle().fillColor.r,
							$rootScope.getDrawStyle().fillColor.g,
							$rootScope.getDrawStyle().fillColor.b,
							$rootScope.getDrawStyle().fillOpacity]));
				return pointSymbol;
			},

			/* 
			 * 获取线样式
			 */
			getDrawLineSymbol : function(){ 
				// 线样式
				var lineSymbol = new esri.symbol.SimpleLineSymbol(
					esri.symbol.SimpleLineSymbol.STYLE_SOLID,
					new dojo.Color([$rootScope.getDrawStyle().strokeColor.r,
							$rootScope.getDrawStyle().strokeColor.g,
							$rootScope.getDrawStyle().strokeColor.b,
							$rootScope.getDrawStyle().fillOpacity]), 2);
				return lineSymbol;
			},

			/* 
			 * 获取填充样式
			 */
			getDrawFillSymbol : function(){ 
				// 面样式
				var fillSymbol = new esri.symbol.SimpleFillSymbol(
					esri.symbol.SimpleFillSymbol.STYLE_SOLID,
					this.lineSymbol, new dojo.Color([
							$rootScope.getDrawStyle().fillColor.r,
							$rootScope.getDrawStyle().fillColor.g,
							$rootScope.getDrawStyle().fillColor.b,
							$rootScope.getDrawStyle().fillOpacity]));
				return fillSymbol;
			},

			/* 
			 * 定义默认选中样式
			 */
			getDefaultPointSyml : function(){ 
				// 点样式
				var pointSymbol = new esri.symbol.SimpleMarkerSymbol(
					esri.symbol.SimpleMarkerSymbol.STYLE_CIRCLE, 10,
					new esri.symbol.SimpleLineSymbol(
							esri.symbol.SimpleLineSymbol.STYLE_SOLID,
							new dojo.Color([
								$rootScope.getHighLightDefaultStyle().strokeColor.r,
								$rootScope.getHighLightDefaultStyle().strokeColor.g,
								$rootScope.getHighLightDefaultStyle().strokeColor.b]), 1),
					new dojo.Color([$rootScope.getHighLightDefaultStyle().fillColor.r,
							$rootScope.getHighLightDefaultStyle().fillColor.g,
							$rootScope.getHighLightDefaultStyle().fillColor.b,
							$rootScope.getHighLightDefaultStyle().fillOpacity]));
				return pointSymbol;
			},
			
			/* 
			 * 定义默认选中样式
			 */
			getDefaultLineSyml : function(){ 
				// 线样式
				var outlineSyml = new esri.symbol.SimpleLineSymbol(
					esri.symbol.SimpleLineSymbol.STYLE_SOLID, new dojo.Color([
						$rootScope.getHighLightDefaultStyle().strokeColor.r,
						$rootScope.getHighLightDefaultStyle().strokeColor.g,
						$rootScope.getHighLightDefaultStyle().strokeColor.b,
						$rootScope.getHighLightDefaultStyle().fillOpacity]),
					$rootScope.getHighLightDefaultStyle().strokeWidth);
				return outlineSyml;
			},

			/* 
			 * 定义默认选中样式
			 */
			getDefaultFillSyml : function(){ 
				// 线样式
				var outlineSyml = new esri.symbol.SimpleLineSymbol(
					esri.symbol.SimpleLineSymbol.STYLE_SOLID, new dojo.Color([
						$rootScope.getHighLightDefaultStyle().strokeColor.r,
						$rootScope.getHighLightDefaultStyle().strokeColor.g,
						$rootScope.getHighLightDefaultStyle().strokeColor.b,
						$rootScope.getHighLightDefaultStyle().fillOpacity]),
					$rootScope.getHighLightDefaultStyle().strokeWidth);
		
				var selectFillSyml = new esri.symbol.SimpleFillSymbol(
					esri.symbol.SimpleFillSymbol.STYLE_SOLID, outlineSyml,
					new dojo.Color([$rootScope.getHighLightDefaultStyle().fillColor.r,
						$rootScope.getHighLightDefaultStyle().fillColor.g,
						$rootScope.getHighLightDefaultStyle().fillColor.b,
						$rootScope.getHighLightDefaultStyle().fillOpacity]));
				return selectFillSyml;
			},

			/* 
			 * 定义高亮选中样式
			 */
			getSelectPointSyml : function(){ 
				// 点样式
				var pointSymbol = new esri.symbol.SimpleMarkerSymbol(
					esri.symbol.SimpleMarkerSymbol.STYLE_SQUARE, 15,
					new esri.symbol.SimpleLineSymbol(
							esri.symbol.SimpleLineSymbol.STYLE_SOLID,
							new dojo.Color([
								$rootScope.getHighLightSelectStyle().strokeColor.r,
								$rootScope.getHighLightSelectStyle().strokeColor.g,
								$rootScope.getHighLightSelectStyle().strokeColor.b]), 1),
					new dojo.Color([$rootScope.getHighLightSelectStyle().fillColor.r,
							$rootScope.getHighLightSelectStyle().fillColor.g,
							$rootScope.getHighLightSelectStyle().fillColor.b,
							$rootScope.getHighLightSelectStyle().fillOpacity]));
				return pointSymbol;
			},
			
			/* 
			 * 定义高亮选中样式
			 */
			getSelectLineSyml : function(){ 
				// 线样式
				var outlineSyml = new esri.symbol.SimpleLineSymbol(
					esri.symbol.SimpleLineSymbol.STYLE_SOLID, new dojo.Color([
						$rootScope.getHighLightSelectStyle().strokeColor.r,
						$rootScope.getHighLightSelectStyle().strokeColor.g,
						$rootScope.getHighLightSelectStyle().strokeColor.b,
						$rootScope.getHighLightSelectStyle().fillOpacity]),
					$rootScope.getHighLightSelectStyle().strokeWidth);
				return outlineSyml;
			},

			/* 
			 * 定义高亮选中样式
			 */
			getSelectFillSyml : function(){ 
				// 线样式
				var outlineSyml = new esri.symbol.SimpleLineSymbol(
					esri.symbol.SimpleLineSymbol.STYLE_SOLID, new dojo.Color([
						$rootScope.getHighLightSelectStyle().strokeColor.r,
						$rootScope.getHighLightSelectStyle().strokeColor.g,
						$rootScope.getHighLightSelectStyle().strokeColor.b,
						$rootScope.getHighLightSelectStyle().fillOpacity]),
					$rootScope.getHighLightSelectStyle().strokeWidth);
		
				var selectFillSyml = new esri.symbol.SimpleFillSymbol(
					esri.symbol.SimpleFillSymbol.STYLE_SOLID, outlineSyml,
					new dojo.Color([$rootScope.getHighLightSelectStyle().fillColor.r,
						$rootScope.getHighLightSelectStyle().fillColor.g,
						$rootScope.getHighLightSelectStyle().fillColor.b,
						$rootScope.getHighLightSelectStyle().fillOpacity]));
				return selectFillSyml;
			},

			/**
			 * 添加graphic
			 * geometry 线对象，guid 全局唯一值
			 */
			addLineGraphic : function(geometry, guid){
				var gh = $rootScope.gisObject.map.graphics;
				if(!gh){
					return null;
				}
				guid = guid ? guid : $rootScope.getGUID();
				// 先添加绘制图形
				var symbol = $rootScope.getDrawLineSymbol();
				var graphic = new esri.Graphic(geometry, symbol);
				if(!graphic.attributes){
					graphic.attributes = {};
				}
				graphic.attributes.$guid = guid;
				gh.add(graphic);
				return graphic;
			},

			/**
			 * 添加graphic
			 * geometry 线对象，guid 全局唯一值
			 */
			addPolygonGraphic : function(geometry, guid){
				var gh = $rootScope.gisObject.map.graphics;
				if(!gh){
					return null;
				}
				guid = guid ? guid : $rootScope.getGUID();
				// 先添加绘制图形
				var symbol = $rootScope.getDrawFillSymbol();
				var graphic = new esri.Graphic(geometry, symbol);
				if(!graphic.attributes){
					graphic.attributes = {};
				}
				graphic.attributes.$guid = guid;
				gh.add(graphic);
				return graphic;
			},

			/**
			 * 添加graphic
			 * text 显示的字符，_center 中心点，guid 全局唯一值,clickClose 是否点击后可删除
			 */
			addLabelGraphic : function(text, _center, guid, clickClose){
				var gh = $rootScope.gisObject.map.graphics;
				if(!gh){
					return null;
				}
				guid = guid ? guid : $rootScope.getGUID();
				var font = new esri.symbol.Font("13px",
						esri.symbol.Font.STYLE_NORMAL,
						esri.symbol.Font.VARIANT_NORMAL,
						esri.symbol.Font.WEIGHT_BOLDER);
				var textSymbol = new esri.symbol.TextSymbol(text, font, new dojo.Color([0, 0, 0]));
				var labelPointGraphic = new esri.Graphic(_center, textSymbol);
				if(!labelPointGraphic.attributes){
					labelPointGraphic.attributes = {};
				}
				labelPointGraphic.attributes.$guid = guid;
				if(clickClose==true){
					labelPointGraphic.attributes.$clickClose = true;
				}
				gh.add(labelPointGraphic);
				return labelPointGraphic;
			},

			/**
			 * 级联删除，应用于测量后提示用户点删除对象时删除
			 */
			superRemoveGraphic : function(graphic){
				if(!graphic.attributes){
		    		return;
		    	}
		    	var gh = $rootScope.gisObject.map.graphics;

		    	if(graphic.attributes.$clickClose==true){
		    		var _guid = graphic.attributes.$guid;
		    		gh.remove(graphic);

			    	//遍历地图的graphics查找guid一样的内容
				   	for(var i=0;i<gh.graphics.length;i++){
				      	var cGrapphic=gh.graphics[i];
				      	if(cGrapphic.attributes
				      		&& cGrapphic.attributes.$guid==_guid){
				         	gh.remove(cGrapphic);
				         	break;
				      	}
				   	}
		    	}
			},

			/**
			 * 简单添加graphic
			 */
			addGraphic : function(geometry){
				var symbol = $rootScope.getSelectFillSyml();
		       	if(geometry.type == "point"){
		       		symbol = $rootScope.getSelectPointSyml();
		       	}else if(geometry.type == "polyline"){
		       		symbol = $rootScope.getSelectLineSyml();
		       	}
				var graphic = new esri.Graphic(geometry, symbol);
	          	$rootScope.gisObject.map.graphics.add(graphic);
	          	return graphic;
	        },

	        /**
			 * 获取Graphic
			 */
			getGraphic : function(id, keyName) {
				var graphic = null;
				keyName = keyName ? keyName : '_guid';

				var gh = $rootScope.gisObject.map.graphics;
			   	//遍历地图的graphics查找OBJECTID和点击行的OBJECTID相同的Grapphic
			   	for(var i=0;i<gh.graphics.length;i++){
			      	var cGrapphic=gh.graphics[i];
			      	if(cGrapphic.attributes && cGrapphic.attributes[keyName]==id){
			         	graphic=cGrapphic;
			         	break;
			      	}
			   	}
			   	return graphic;
			},

	        /**
			 * 简单feature选中
			 * feature 要素，it 弹窗信息
			 */
			addFeatureSelectGraphic : function(feature, it){
				// 默认选中样式
		       	var symbol = $rootScope.getDefaultFillSyml();
		       	if(feature.geometry.type == "point"){
		       		symbol = $rootScope.getDefaultPointSyml();
		       	}else if(feature.geometry.type == "polyline"){
		       		symbol = $rootScope.getDefaultLineSyml();
		       	}
          		feature.attributes.$isFeature = true;
				var graphic = new esri.Graphic(feature.geometry, symbol);
				graphic.defaultSymbol = symbol;
          		graphic.attributes = feature.attributes;
          		graphic.setInfoTemplate(it);
	          	$rootScope.gisObject.map.graphics.add(graphic);
	          	return graphic;
	        },

	        /**
			 * 简单feature 添加 pop 小气泡
			 * feature 要素，it 弹窗信息
			 */
			addFeaturePopGraphic : function(feature, i, it){
				feature.attributes.$ispop = true;
				feature.attributes.$popindxe = i;

				var iconName = "";
				if(i<=9){
					iconName = i.toString();
				}else{
					iconName = "arrow";
				}
				var iconURL = getBasePath()+"/arcgis/images/features/" + iconName + ".png";
				var pMark = new esri.symbol.PictureMarkerSymbol(iconURL, 25, 25);
				var _center = $rootScope.getCenter(feature.geometry);
				var graphic = new esri.Graphic(_center, pMark);
				graphic.attributes = feature.attributes;
				graphic.setInfoTemplate(it);
				$rootScope.gisObject.map.graphics.add(graphic);
				return graphic;
	        },

			/**
			 * 高亮选中小气泡
			 */
		    highFeaturePopGraphic : function(id, keyName){
		    	var graphic = $rootScope.getGraphic(id, keyName);
			   	if(!graphic){
			   		return;
			   	}
			   	$rootScope.highFeaturePopGraphicEx(graphic);
		    },

		    /**
			 * 高亮选中小气泡
			 */
		    highFeaturePopGraphicEx : function(graphic){
			   	if(!graphic){
			   		return;
			   	}

			   	// 如果是自定义小气泡
		    	var i = graphic.attributes.$popindxe;
		    	// 设置小气泡
				var iconName = "";
				if(i<=9){
					iconName = "b"+i.toString();
				}else{
					iconName = "arrow";
				}
				var iconURL = getBasePath()+"/arcgis/images/features/" + iconName + ".png";
				var pMark = new esri.symbol.PictureMarkerSymbol(iconURL, 30, 30);
				graphic.setSymbol(pMark);
		    },

		    /**
			 * 高亮选中查询要素
			 */
		    highFeatureSelectGraphic : function(id, keyName){
		    	var graphic = $rootScope.getGraphic(id, keyName);
			   	if(!graphic){
			   		return;
			   	}
				$rootScope.highFeatureSelectGraphicEx(graphic);
		    },

		    /**
			 * 高亮选中查询要素
			 */
		    highFeatureSelectGraphicEx : function(graphic){
			   	if(!graphic){
			   		return;
			   	}

			   	var symbol = $rootScope.getSelectFillSyml();
		       	if(graphic.geometry.type == "point"){
		       		symbol = $rootScope.getSelectPointSyml();
		       	}else if(graphic.geometry.type == "polyline"){
		       		symbol = $rootScope.getSelectLineSyml();
		       	}
				graphic.setSymbol(symbol);
		    },

		    /**
			 * 取消高亮选中小气泡
			 */
		    featurePopGraphic : function(id, keyName){
		    	var graphic = $rootScope.getGraphic(id, keyName);
			   	if(!graphic){
			   		return;
			   	}
			   	$rootScope.featurePopGraphicEx(graphic);
		    },

		    /**
			 * 取消高亮选中小气泡
			 */
		    featurePopGraphicEx : function(graphic){
			   	if(!graphic){
			   		return;
			   	}
			   	
			   	// 如果是自定义小气泡
		    	var i = graphic.attributes.$popindxe;
		    	var iconName = "";
				if(i<=9){
					iconName = i.toString();
				}else{
					iconName = "arrow";
				}
				var iconURL = getBasePath()+"/arcgis/images/features/" + iconName + ".png";
				var pMark = new esri.symbol.PictureMarkerSymbol(iconURL, 25, 25);
				graphic.setSymbol(pMark);
		    },

		    /**
			 * 取消高亮选中查询要素
			 */
		    featureSelectGraphic : function(id, keyName){
		    	var graphic = $rootScope.getGraphic(id, keyName);
			   	if(!graphic){
			   		return;
			   	}
				$rootScope.featureSelectGraphicEx(graphic);
		    },

		    /**
			 * 取消高亮选中查询要素
			 */
		    featureSelectGraphicEx : function(graphic){
			   	if(!graphic){
			   		return;
			   	}
			   	var symbol = graphic.defaultSymbol;
			   	if(symbol == null){
			   		symbol = $rootScope.getDefaultFillSyml();
			       	if(graphic.geometry.type == "point"){
			       		symbol = $rootScope.getDefaultPointSyml();
			       	}else if(graphic.geometry.type == "polyline"){
			       		symbol = $rootScope.getDefaultLineSyml();
			       	}
			   	}
				graphic.setSymbol(symbol);
		    },

		    /**
			 * 显示详细信息窗口
			 */
		    showInfoWindow : function (id, keyName){
		    	var graphic = $rootScope.getGraphic(id, keyName);
			   	if(!graphic){
			   		return;
			   	}

		    	$rootScope.showInfoWindowEx(graphic);
		    	return true;
		    },

            /**
             * 显示内容自定义处理方法
             */
            ArcGisInfoWindowContentOption:null,

		    /**
			 * 显示详细信息窗口
			 */
		    showInfoWindowEx : function(graphic){
			   	if(!graphic){
			   		return;
			   	}

			   	var map = $rootScope.gisObject.map;
		    	var title = graphic.getTitle();
				var content = graphic.getContent();
				if(title==null || content==null){
					return;
				}
		       	map.infoWindow.setTitle(title);
				if($rootScope.ArcGisInfoWindowContentOption){
                    content = $rootScope.ArcGisInfoWindowContentOption(content,graphic.attributes);
                }
		       	map.infoWindow.setContent(content);
		       	var _extent = $rootScope.getCenter(graphic.geometry);
		       	map.infoWindow.show(_extent);
		    },

		    selectPopAndFeature : function(id, keyName){
		    	$rootScope.featurePopGraphic(id, keyName);
		    	$rootScope.featureSelectGraphic(id, keyName);
		    },

		    highSelectPopAndFeature : function(id, keyName){
		    	$rootScope.highFeaturePopGraphic(id, keyName);
		    	$rootScope.highFeatureSelectGraphic(id, keyName);
		    },

			/* 
			 * 清除所有标注
			 */
			clearGraphics : function(){
				var map = $rootScope.gisObject.map;
				if(!$rootScope.isNullOrUndefined(map)
					&& !$rootScope.isNullOrUndefined(map.graphics)){
					map.graphics.clear();
				}
			},

			/**
			 * 绽放到
			 */
		    setGraphicExtent : function(id, keyName){
		    	var graphic = $rootScope.getGraphic(id, keyName);
			   	if(!graphic){
			   		return;
			   	}
				//设置地图视图范围
		       	var rExtent = $rootScope.getMaxExtent([graphic]);
		    	$rootScope.gisObject.map.setExtent(rExtent);
		    }
		};
		for(f in $arcgis_graphic){
			$rootScope[f] = $arcgis_graphic[f];
		}
		return $arcgis_graphic;
	}]).run(["$rootScope", "$arcgis_graphic", function($rootScope, $arcgis_graphic) { }]);
}(window, angular));
(function(window, angular, undefined){
	angular.module('arcgis.measure', [])
	.factory('$arcgis_measure', ["$rootScope", function($rootScope) {
		$arcgis_measure = {

			/**
			 * 测试距离
			 * 
			 * @function {public} ?
			 */
			lengthMeasure : function() {
				$rootScope.drawPolyline(function(geometry){
					$rootScope.deDraw();
					$rootScope.getGeometryLength([geometry], function(result){
						$rootScope.showLengthMeasure(result, geometry);
					});
				});

				var map = $rootScope.gisObject.map;
				if(!$rootScope.isNullOrUndefined(map)){
					map.setMapCursor("url("+getBasePath()+"/arcgis/images/cur/ruler.cur),auto");
				}
			},

			// 显示测量距离
			showLengthMeasure : function(result, geometry){
				var map = $rootScope.gisObject.map;
			   	if (result && map.graphics != null) {
			   		var guid = $rootScope.getGUID();
			   		var _center = $rootScope.getCenter(geometry);
			   		var resultStr = Number(result.lengths[0]).toFixed(3) + " 公里(关闭)";

			   		$rootScope.addLineGraphic(geometry,guid);
			   		$rootScope.addLabelGraphic(resultStr,_center,guid,true);

					// 启用map.graphics的鼠标事件
				    map.graphics.enableMouseEvents();
			       	var handler = dojo.connect(map.graphics, "onClick", function (evt){
			       		dojo.disconnect(handler);
			       		$rootScope.superRemoveGraphic(evt.graphic);
			    	});
				}
			},

			/**
			 * 测试面积
			 * 
			 * @function {public} ?
			 */
			areaMeasure : function() {
				$rootScope.drawPolygon(function(geometry){
					$rootScope.deDraw();
					$rootScope.getGeometryArea([geometry], function(result){
						$arcgis_measure.showAreaMeasure(result, geometry);
					});
				});

				var map = $rootScope.gisObject.map;
				if(!$rootScope.isNullOrUndefined(map)){
					map.setMapCursor("url("+getBasePath()+"/arcgis/images/cur/ruler.cur),auto");
				}
			},

			// 显示测量面积
			showAreaMeasure : function(result, geometry){
				var map = $rootScope.gisObject.map;
			   	if (result && map.graphics != null) {
			   		var guid = $rootScope.getGUID();
			   		var _center = $rootScope.getCenter(geometry);
			   		var resultStr = Number(result.areas[0]).toFixed(3) + "平方公里(单击关闭)";

			   		$rootScope.addPolygonGraphic(geometry,guid);
			   		$rootScope.addLabelGraphic(resultStr,_center,guid,true);

					// 启用map.graphics的鼠标事件
				    map.graphics.enableMouseEvents();
			       	var handler = dojo.connect(map.graphics, "onClick", function (evt){
			       		dojo.disconnect(handler);
			       		$rootScope.superRemoveGraphic(evt.graphic);
			    	});
				}
			}
		};
		for(f in $arcgis_measure){
			$rootScope[f] = $arcgis_measure[f];
		}
		return $arcgis_measure;
	}])
	.run(["$rootScope", "$arcgis_measure", function($rootScope, $arcgis_measure) { }]);
}(window, angular));
(function(window, angular, undefined){
	angular.module('arcgis.printing', [])
	.factory('$arcgis_printing', ["$rootScope", function($rootScope) {
		$arcgis_printing = {

			// gisObject.printingService 打印服务
			
			// 打印
			printImage : function() {
				var go = $rootScope.gisObject;
								//var dpi_temp=$arcgis_printing.js_getDPI();
				var xs=96/30.0;
				if(go.printingService){
					var template = new esri.tasks.PrintTemplate();
					template.exportOptions = { width: Math.round(go.map.width*xs), height: Math.round(go.map.height*xs), dpi: 96};
					template.format = "PDF";
					template.layout = "MAP_ONLY";
					template.preserveScale = true;
					var params = new esri.tasks.PrintParameters();
					params.map = go.map;
					params.template = template;
					go.printStatus = {printing:false};
					go.printStatus.printing = true;
					go.printingService.execute(params, function(renderer) {
						if (renderer != null) {
							window.open(renderer.url);
						}
						go.printStatus.printing = false;
					},function(error){
						go.printStatus.printing = false;
					});
				}
			}
			/*,
			js_getDPI:function () {
			    var arrDPI = new Array;
			    if (window.screen.deviceXDPI) {
			        arrDPI[0] = window.screen.deviceXDPI;
			        arrDPI[1] = window.screen.deviceYDPI;
			    }
			    else {
			        var tmpNode = document.createElement("DIV");
			        tmpNode.style.cssText = "width:1in;height:1in;position:absolute;left:0px;top:0px;z-index:99;visibility:hidden";
			        document.body.appendChild(tmpNode);
			        arrDPI[0] = parseInt(tmpNode.offsetWidth);
			        arrDPI[1] = parseInt(tmpNode.offsetHeight);
			        tmpNode.parentNode.removeChild(tmpNode);    
			    }
			    return arrDPI;
			}*/
		};
		for(f in $arcgis_printing){
			$rootScope[f] = $arcgis_printing[f];
		}
		return $arcgis_printing;
	}]).run(["$rootScope", "$arcgis_printing", function($rootScope, $arcgis_printing) { }]);
}(window, angular));
(function(window, angular, undefined){
	angular.module('arcgis.toolbar', [])
	.factory('$arcgis_toolbar', ["$rootScope", function($rootScope) {
		$arcgis_toolbar = {
			// 放大
			mapZoomin : function(){
				// go.map.setMapCursor("default");
				var go = $rootScope.gisObject;
				if(!$rootScope.isNullOrUndefined(go.map)){
					go.map.setMapCursor("url("+getBasePath()+"/arcgis/images/cur/zoomin.cur),auto");
				}
				
				if(!$rootScope.isNullOrUndefined(go.navToolbar)){
					go.navToolbar.activate(esri.toolbars.Navigation.ZOOM_IN);
				}
			},

			// 缩小
			mapZoomout : function(){
				var go = $rootScope.gisObject;
				if(!$rootScope.isNullOrUndefined(go.map)){
					go.map.setMapCursor("url("+getBasePath()+"/arcgis/images/cur/zoomout.cur),auto");
				}
				
				if(!$rootScope.isNullOrUndefined(go.navToolbar)){
					go.navToolbar.activate(esri.toolbars.Navigation.ZOOM_OUT);
				}
			},

			// 平移
			mapPan : function(){
				var go = $rootScope.gisObject;
				if(!$rootScope.isNullOrUndefined(go.map)){
					go.map.setMapCursor("url("+getBasePath()+"/arcgis/images/cur/hand.cur),auto");
				}
				try{
					if(!$rootScope.isNullOrUndefined(go.navToolbar)){
						go.navToolbar.activate(esri.toolbars.Navigation.PAN);
					}
				}catch(e){
				}
			},

			// 全图
			mapFullextent : function(){
				var go = $rootScope.gisObject;
				if(!$rootScope.isNullOrUndefined(go.navToolbar)){
					go.navToolbar.zoomToFullExtent();
				}
			},

			// 全图
			mapFullextentEx : function(){
				var go = $rootScope.gisObject;
				if(go.fullExtent){
					go.map.setExtent(go.fullExtent);
				}
			},

			// 上一视图
			mapToprev : function(){
				var go = $rootScope.gisObject;
				if(!$rootScope.isNullOrUndefined(go.navToolbar)){
					go.navToolbar.zoomToPrevExtent();
				}
			},

			// 下一视图
			mapTonext : function(){
				var go = $rootScope.gisObject;
				if(!$rootScope.isNullOrUndefined(go.navToolbar)){
					go.navToolbar.zoomToNextExtent();
				}
			},

			/**
			 * 重新刷新地图
			 * 
			 * @function {public} ?
			 */
			reflashMap : function() {
				var go = $rootScope.gisObject;
				if(go && go.map){
					go.map.resize(true);
					go.map.reposition();
				}
			}
		};
		for(f in $arcgis_toolbar){
			$rootScope[f] = $arcgis_toolbar[f];
		}
		return $arcgis_toolbar;
	}]).run(["$rootScope", "$arcgis_toolbar", function($rootScope, $arcgis_toolbar) { }]);
}(window, angular));
(function(window, angular, undefined){
	angular.module('arcgis.utils', [])
	.factory('$arcgis_utils', ["$rootScope", function($rootScope) {
		$arcgis_utils = {

			getMapExtent : function(){
				var extent = $rootScope.gisObject.map.extent;
				return extent.xmin + "," + extent.ymin + "," 
						+ extent.xmax + "," + extent.ymax;
			},

			/**
			 * 获取要素集的最大视图范围
			 * 
			 * @param { [
			 *            <esri.layer.GraphicLayer>]} features 目标对象
			 * @param {
			 *            <Number>} zoomFactor
			 * @return {esri.geometry.Extent}
			 */
			getMaxExtent : function(features, zoomFactor) {
				if (features.length < 0) {
					return false;
				}
				if (!zoomFactor)
					zoomFactor = 1;
				var extent = new esri.geometry.Extent();  
				//根据第一个不为null的geometry判断geometry类型
				for(var i = 0;i<features.length;i++){
					var _geometry = features[i].geometry;
					if(!_geometry || _geometry == null)
						continue;
					if (_geometry.type == "polygon"){
						//将范围进行叠加
						for (var j = 0; j < features.length; j++) {
							if(features[j].geometry)
								if(extent.xmin&&extent.xmax&&extent.ymin&&extent.ymax){
									extent = extent.union(features[j].geometry.getExtent());
								}
								else{
									extent = features[j].geometry.getExtent();
								}
						}
						extent = extent.expand(zoomFactor);
					} else if (_geometry.type == "point") {
						var pointX;
						var pointY;
						var pointXArr = [];
						var pointYArr = [];
						for (var j = 0; j < features.length; j++) {
							if(features[j].geometry){
								pointX = features[j].geometry.x;
								pointY = features[j].geometry.y;
								pointXArr.push(pointX);
								pointYArr.push(pointY);
							}
						}
						var maxX = Math.max.apply(null, pointXArr) + 0.1;
						var minX = Math.min.apply(null, pointXArr) - 0.1;
						var maxY = Math.max.apply(null, pointYArr) + 0.1;
						var minY = Math.min.apply(null, pointYArr) - 0.1;
						extent = new esri.geometry.Extent(minX, minY, maxX, maxY,
								_geometry.spatialReference).expand(zoomFactor);
					} else {
						//将范围进行叠加
						for (var j = 0; j < features.length; j++) {
							if(features[j].geometry)
								if(extent.xmin&&extent.xmax&&extent.ymin&&extent.ymax){
									extent = extent.union(features[j].geometry.getExtent());
								}
								else{
									extent = features[j].geometry.getExtent();
								}
						}
						extent = extent.expand(zoomFactor);
					}
					break;
				}
				// 调整返回的extent大小
				var _x = extent.xmax - extent.xmin;
				var _y = extent.ymax - extent.ymin;
				extent.xmax = extent.xmax + (_x / 3);
				extent.xmin = extent.xmin - (_x / 3);
				extent.ymax = extent.ymax + (_y / 3);
				extent.ymin = extent.ymin - (_y / 3);
				extent.spatialReference = $rootScope.gisObject.mapwkid;
				return extent;
			}, 

			/**
			 * 获取Geometry的中心点
			 * 
			 * @function {public} ?
			 * @param {esri.geometry.Geometry}
			 *            geometry - 几何对象
			 * @return point - 点对象
			 */
			getCenter : function(geometry) {
				var _point;
				if (geometry.type == "point") {
					_point = geometry;
				} else if (geometry.type == "polygon") {
					_point = geometry.getExtent().getCenter();
				} else if(geometry.type == "polyline"){
					var ptnArr = geometry.paths[0][geometry.paths[0].length - 1];
					_point = new esri.geometry.Point(ptnArr[0], ptnArr[1], geometry.spatialReference);
				} else {
					_point = geometry.getExtent().getCenter();
				}
				return _point;
			},

			/**
			 * 根据字符串获取Extent对象
			 * 
			 * @function {public} ?
			 */
			getExtentByString : function(extentStr, wkid) {
				var extentArray = extentStr.split(",");
				var extent = new esri.geometry.Extent({
							"xmin" : parseFloat(extentArray[0]),
							"ymin" : parseFloat(extentArray[1]),
							"xmax" : parseFloat(extentArray[2]),
							"ymax" : parseFloat(extentArray[3]),
							"spatialReference" : wkid
						});
				return extent;
			},

			/**
			 * 把度分秒的经纬度转换成度的经纬度
			 */
			DMSConvertToDegree : function(strcoordinateD, strcoordinateM, strcoordinateS) {
				if (!$rootScope.validateNum(strcoordinateD)
						|| !$rootScope.validateNum(strcoordinateM)
						|| !$rootScope.validateNum(strcoordinateS)) {
					return "";
				}
				icoordinateD = parseInt(strcoordinateD);
				icoordinateM = parseInt(strcoordinateM) / 60;
				icoordinateS = parseInt(strcoordinateS) / 3600;
				return icoordinateD + icoordinateM + icoordinateS;
			},
			
			//抽稀，参数：esri的feature对象数组
			featureSimple : function(features){
				if(!features){
					return null;
				}
				var resultFeature = [];
				var buf = $rootScope.gisObject.map.getResolution() * 30;
				
				for(var i=0;i<features.length;i++){
					var feature = features[i];
					if(resultFeature.length == 0){
						resultFeature.push(feature);
						continue;
					}
					if($rootScope.isContantFeature(resultFeature,feature,buf)){
						resultFeature.push(feature);
					}
				}
				return resultFeature;
			},
						
			isContantFeature : function(featureList, targetfeature, buf){
				var targetCenterPoint = $rootScope.getCenter(targetfeature.geometry);
				for(var j=0;j<featureList.length;j++){
					var currentCenterPoint = $rootScope.getCenter(featureList[j].geometry);
					if(Math.abs(targetCenterPoint.x - currentCenterPoint.x) <= buf && 
							Math.abs(targetCenterPoint.y - currentCenterPoint.y) <= buf){
						return false;
					}
				}
				return true;
			}
		};
		for(f in $arcgis_utils){
			$rootScope[f] = $arcgis_utils[f];
		}
		return $arcgis_utils;
	}])
	.run(["$rootScope", "$arcgis_utils", function($rootScope, $arcgis_utils) { }]);
}(window, angular));
(function(window, angular, undefined){
	angular.module('arcgis.base', ['arcgis.draw','arcgis.geometryservice','arcgis.graphic','arcgis.measure','arcgis.printing','arcgis.toolbar','arcgis.utils']);
}(window, angular));
(function(window, angular, undefined){
	angular.module('arcgis.locator', [])
	.factory('$arcgis_locator', ["$rootScope", function($rootScope) {
		$arcgis_locator = {

			// 参数：定位器 : locator, locatorLevel : 缩放级别
			
			/* 
			 * 地址编码定位
			 */
			addressToLocations : function(name, onComplete){
				var go = $rootScope.gisObject;
				if(!$rootScope.isNullOrUndefined(go.locator)){
					var handler = dojo.connect(go.locator, "onAddressToLocationsComplete", function(candidate) {
						dojo.disconnect(handler);
						if(onComplete) onComplete(candidate);
					});
					go.locator.addressToLocations({SingleKey:name});
				}
			},

	         /* 
			 * 定位到指定名称的地址
			 */
			mapAddressLocator : function(name, level){
				var go = $rootScope.gisObject;
				var tempName=name;
				if(!$rootScope.isNullOrUndefined(go.locator)){
					go.locatorLevel = level ? level : 8;
					$rootScope.addressToLocations(name, function(candidate) {
			            if (candidate && candidate.length>0) {
			            	for(var k=0;k<candidate.length;k++){
			            		var iCan= candidate[k];
			            		if(iCan.address==tempName){
			            			var adr = iCan;
			                		var location = adr.location;
			                		location.spatialReference = go.mapwkid;
			                		go.map.centerAndZoom(location, go.locatorLevel);
			            		}
			            	}
			            }
			        });
				}
			},

			/* 
			 * 经纬度定位
			 */
			mapJwdLocator : function(lonD,lonF,lonM,latD,latF,latM){
				$rootScope.deDrawAndClearGraphics();
				if (lonD > 180 || lonD < 0) {
					alert("【经度】:'度'范围 必须介于0~180之间,请重新输入");
					return;
				}
				if (latD > 90 || latD < 0) {
					alert("【纬度】:'度'范围必须介于0~90之间,请重新输入");
					return;
				}
				if (lonF > 60 || latF > 60 || lonF < 0 || latF < 0) {
					alert("'分' 范围必须介于0~60之间,请重新输入");
					return;
				}
				if (lonM > 60 || latM > 60 || lonM < 0 || latM < 0) {
					alert("'秒' 范围必须介于0~60之间,请重新输入");
					return;
				}

				var lon = $rootScope.DMSConvertToDegree(lonD, lonF, lonM);
				var lat = $rootScope.DMSConvertToDegree(latD, latF, latM);

				if (lat == "" || lon == "") {
					alert("请输入正确的经纬度");
					return;
				}

				var go = $rootScope.gisObject;
				var rPoint = new esri.geometry.Point();
				rPoint.x = lon;
				rPoint.y = lat;
				rPoint.spatialReference = go.dlwkid;

				// 如果是地理坐标，就直接定位
				if(go.mapisdlwkid){
					$rootScope.mapLocation(rPoint);
				}else{
					// 先转换，再定位
					$rootScope.geoProject([rPoint], go.tywkid, function(graphics){
						$rootScope.mapLocation(graphics[0]);
					});
				}
			},

			/* 
			 * 地理坐标定位
			 */
			mapDlLocator : function(x, y){
				var go = $rootScope.gisObject;
				$rootScope.deDrawAndClearGraphics();
				var rPoint = new esri.geometry.Point();
				rPoint.x = x;
				rPoint.y = y;
				rPoint.spatialReference = go.dlwkid;

				// 如果是地理坐标，就直接定位
				if(go.mapisdlwkid){
					$rootScope.mapLocation(rPoint);
				}else{
					// 先转换，再定位
					$rootScope.geoProject([rPoint], go.tywkid, function(graphics){
						$rootScope.mapLocation(graphics[0]);
					});
				}
			},

			/* 
			 * 平面坐标定位
			 */
			mapPmLocator : function(x, y){
				var go = $rootScope.gisObject;
				$rootScope.deDrawAndClearGraphics();
				var rPoint = new esri.geometry.Point();
				rPoint.x = x;
				rPoint.y = y;
				rPoint.spatialReference = go.tywkid;

				// 如果是地理坐标，先转换，再定位
				if(go.mapisdlwkid){
					$rootScope.geoProject([rPoint], go.dlwkid, function(graphics){
						$rootScope.mapLocation(graphics[0]);
					});
				}else{
					// 就直接定位
					$rootScope.mapLocation(rPoint);
				}
			},

			/* 
			 * 坐标定位
			 */
			mapLocation : function(rPoint){
				var go = $rootScope.gisObject;
				var _extent = go.fullExtent;
				if (!_extent.contains(rPoint)) {
					alert("坐标信息不在范围之内");
					return;
				}

				go.map.centerAndZoom(rPoint,15);

				// 设置小气泡
				var iconURL = getBasePath()+"/arcgis/images/features/arrow.png";
				var pMark = new esri.symbol.PictureMarkerSymbol(iconURL, 25, 25);
				var _center = $rootScope.getCenter(rPoint);
				var graphic = new esri.Graphic(_center, pMark);
				go.map.graphics.add(graphic);
			}
		};
		for(f in $arcgis_locator){
			$rootScope[f] = $arcgis_locator[f];
		}
		return $arcgis_locator;
	}]).run(["$rootScope", "$arcgis_locator", function($rootScope, $arcgis_locator) {}]);
}(window, angular));
(function(window, angular, undefined){
	angular.module('arcgis.map.base', [])
	.factory('$arcgis_map_base', ["$rootScope", function($rootScope) {
		$arcgis_map_base = {

			// 实始化地图基础对象
			initMapBase : function(){
				// 初始化绘制对象
				$rootScope.gisObject.navToolbar = new esri.toolbars.Navigation($rootScope.gisObject.map);
				// 设置测量对象
	            $rootScope.gisObject.drawToolbars = new esri.toolbars.Draw($rootScope.gisObject.map);
			},

			// 处理定位器
			initLocatorService : function(locator){
	            if(locator && locator!=""){
	            	$rootScope.gisObject.locator = new esri.tasks.Locator(locator);
	            }
			},

			//实例化GeometryService，地址为ags发布的GeometryServer
			initGeometryService : function(geometryservice){
				if(geometryservice && geometryservice!=""){
	            	$rootScope.gisObject.geometryService = new esri.tasks.GeometryService(geometryservice);
	            }
			},

			//实例化printingservice，地址为ags发布的printingservice
			initPrintingService : function(printingservice){
				if(printingservice && printingservice!=""){
	            	$rootScope.gisObject.printingService = new esri.tasks.PrintTask(printingservice);
					$rootScope.gisObject.printingService.outSpatialReference = $rootScope.gisObject.mapwkid;
	            }
			}			
		};
		for(f in $arcgis_map_base){
			$rootScope[f] = $arcgis_map_base[f];
		}
		return $arcgis_map_base;
	}])
	.run(["$rootScope", "$arcgis_map_base", function($rootScope, $arcgis_map_base) { }]);
}(window, angular));
(function (window, angular, undefined) {
    angular.module('arcgis.map.layer', [])
        .factory('$arcgis_map_layer', ["$rootScope", function ($rootScope) {
            $arcgis_map_layer = {

                // 瓦片地图服务
                getTiledMapServiceLayer: function (url) {
                    return new esri.layers.ArcGISTiledMapServiceLayer(url);
                },
                // 影像地图服务
                getImageServiceLayer: function (url) {
                    var params = new esri.layers.ImageServiceParameters();
                    params.noData = 0;
                    return new esri.layers.ArcGISImageServiceLayer(url, {
                        imageServiceParameters: params,
                        opacity: 0.75
                    });
                },
                // 动态地图服务
                getDynamicMapServiceLayer: function (url, ldf, vls) {
                    var imageParameters = new esri.layers.ImageParameters();
                    imageParameters.format = "jpeg";
                    //Takes a URL to a non cached map service.
                    var ml = new esri.layers.ArcGISDynamicMapServiceLayer(url, {
                        // "opacity" : 0.5,
                        "imageParameters": imageParameters,
                        vls: vls
                    });

                    // 示例
                    // var layerDefs = [];
                    // layerDefs[5] = "STATE_NAME='Kansas'";
                    // layerDefs[4] = "STATE_NAME='Kansas' and POP2007>25000";
                    if (ldf) {
                        ml.setldf(JSON.parse(ldf)); //开始过滤
                    }
                    return ml;
                },
                // WMS服务
                getWMSLayer: function (url, vls) {
                    var resourceInfo = {
                        extent: new esri.geometry.Extent(-126.40869140625, 31.025390625, -
                            109.66552734375, 41.5283203125),
                        layerInfos: [],
                        version: '1.1.1'
                    };
                    url += "?&ACCOUNT=fujianforest&PASSWD=fujianforest"; // 测试添加帐号，密码
                    var agsWmsLayer = new esri.layers.WMSLayer(url, {
                        resourceInfo: resourceInfo
                    });
                    agsWmsLayer.setImageFormat("png");
                    if (vls != null && vls.length > 0) {
                        agsWmsLayer.setVisibleLayers(vls);
                    } else {
                        agsWmsLayer.setVisibleLayers([0]);
                    }
                    return agsWmsLayer;
                },
                // WMTS服务
                getWMTSLayer: function (url) {
                    var layerInfo = new esri.layers.WMTSLayerInfo({
                        identifier: "opengeo:countries",
                        tileMatrixSet: "EPSG:4326",
                        format: "png"
                    });
                    var options = {
                        serviceMode: "KVP",
                        layerInfo: layerInfo
                    };
                    return new esri.layers.WMTSLayer(url, options);
                },
                // 添加图层
                addLayer: function (url, mtype, ldf, vls, s) {
                    var ml = null;
                    if (mtype == "ArcGISTiledMapServiceLayer") {
                        // 瓦片地图服务
                        ml = $rootScope.getTiledMapServiceLayer(url);
                    } else if (mtype == "ArcGISDynamicMapServiceLayer") {
                        // 动态地图服务
                        ml = $rootScope.getDynamicMapServiceLayer(url, ldf, vls);
                    } else if (mtype == "WMSLayer") {
                        // WMS服务
                        ml = $rootScope.getWMSLayer(url, vls);
                    } else if (mtype == "WMTSLayer") {
                        // WMTS服务
                        ml = $rootScope.getWMTSLayer(url);
                    } else if (mtype == "ArcGISImageServiceLayer") {
                        // 影像地图服务
                        ml = $rootScope.getImageServiceLayer(url);
                    } else if (mtype == "bMapVeclayer") {
                        // 百度地图政区服务
                        ml = arcGISObject.bmapVeclayer;
                    } else if (mtype == "bMapImglayer") {
                        // 百度地图影像服务
                        ml = arcGISObject.bmapImglayer;
                    } else if (mtype == "bMapAnolayer") {
                        // 百度地图标注服务
                        ml = arcGISObject.bmapAnolayer;
                    } else if (mtype == "tdMapAnnoLayer") {
                        // 天地图基础地理标注服务
                        ml = arcGISObject.tdmapAnnoLayer;
                    } else if (mtype == "tdMapLayer") {
                        // 天地图基础地理服务
                        ml = arcGISObject.tdmapLayer;
                    } else if (mtype == "tdMapImgAnnoLayer") {
                        // 天地图影像标注服务
                        ml = arcGISObject.tdmapImgAnnoLayer;
                    } else if (mtype == "tdMapImgLayer") {
                        // 天地图影像服务
                        ml = arcGISObject.tdmapImgLayer;
                    }
                    if (ml == null) return ml;
                    if (s == false) ml.hide();
                    var go = $rootScope.gisObject;
                    go.map.addLayer(ml);

                    return ml;
                },

                // 根据参数，初始化地图
                initMayLayer: function (layers) {
                    if (!layers) return;
                    var validLayers = [];
                    for (var i = layers.length - 1; i >= 0; i--) {
                        var layer = layers[i];
                        if (layer.valid2D == true) {
                            validLayers.push(layer);
                        }
                    }

                    var go = $rootScope.gisObject;
                    go.D2LayerGroup = [];
                    var temp2Dlayer = [];

                    validLayers.forEach(function (layer) {
                        var showids = layer.showids;
                        var vls = null;
                        if (showids && showids != "") {
                            vls = [];
                            var ids = showids.split(",");
                            ids.forEach(function (item) {
                                vls.push(parseInt(item));
                            });
                        }

                        var ml = $rootScope.addLayer(layer.url, layer.type, layer.definitions,
                            vls, layer.show2D);
                        if (ml != null) {
                            var aItem = $rootScope.getArrayItem(temp2Dlayer, 'groupname', layer
                                .groupname);
                            if (aItem == null) {
                                var item = {
                                    groupname: layer.groupname,
                                    layers: [ml],
                                    show: layer.show2D
                                };
                                temp2Dlayer.push(item);
                            } else {
                                aItem.layers.push(ml);
                            }
                        }
                    });
                    for (var i = temp2Dlayer.length - 1; i >= 0; i--) {
                        go.D2LayerGroup.push(temp2Dlayer[i]);
                    }
                },

                // 获取指定分组是否展示
                get2DlayersShow: function (groupname) {
                    var go = $rootScope.gisObject;
                    var aItem = $rootScope.getArrayItem(go.D2LayerGroup, 'groupname', groupname);
                    if (aItem) {
                        return aItem.show;
                    } else {
                        return false;
                    }
                },

                // 设置图层是否显示
                set2DLayersShow: function (groupname, show) {
                    var go = $rootScope.gisObject;
                    var aItem = $rootScope.getArrayItem(go.D2LayerGroup, 'groupname', groupname);
                    if (!aItem) return;
                    show = show == null ? !aItem.show : show;
                    aItem.show = show;
                    aItem.layers.forEach(function (item) {
                        if (show) {
                            item.show();
                        } else {
                            item.hide();
                        }
                    });
                }
            };
            for (f in $arcgis_map_layer) {
                $rootScope[f] = $arcgis_map_layer[f];
            }
            return $arcgis_map_layer;
        }])
        .run(["$rootScope", "$arcgis_map_layer", function ($rootScope, $arcgis_map_layer) {}]);
}(window, angular));

(function(window, angular, undefined){
	angular.module('arcgis.map.ui', [])
	.directive('arcMap', ["$rootScope", "$parse", function($rootScope,$parse) {
		return {
			replace : true,
			restrict : 'E',
			template : '<div></div>',
			link : function(scope, element, attrs, ctrl) {
				var para = eval("("+attrs.para+")");

				var defaultPara = {
					sliderStyle : 'small', // 'large' or 'small'
					lods:[
		             	{"level" : 0, "resolution" : 1.40625, "scale" : 590995186.11750006},
		             	{"level" : 1, "resolution" : 0.703125, "scale" : 295497593.05875003},
			            {"level" : 2, "resolution" : 0.3515625, "scale" : 147748796.52937502},
			            {"level" : 3, "resolution" : 0.17578125, "scale" : 73874398.264687508},
			            {"level" : 4, "resolution" : 0.087890625, "scale" : 36937199.132343754},
			            {"level" : 5, "resolution" : 0.0439453125, "scale" : 18468599.566171877},
			            {"level" : 6, "resolution" : 0.02197265625, "scale" : 9234299.7830859385},
			            {"level" : 7, "resolution" : 0.010986328125, "scale" : 4617149.8915429693},
			            {"level" : 8, "resolution" : 0.0054931640625, "scale" : 2308574.9457714846},
			            {"level" : 9, "resolution" : 0.00274658203125, "scale" : 1154287.4728857423},
			            {"level" : 10, "resolution" : 0.001373291015625, "scale" : 577143.73644287116},
			            {"level" : 11, "resolution" : 0.0006866455078125, "scale" : 288571.86822143558},
			            {"level" : 12, "resolution" : 0.00034332275390625, "scale" : 144285.93411071779},
			            {"level" : 13, "resolution" : 0.000171661376953125, "scale" : 72142.967055358895},
			            {"level" : 14, "resolution" : 0.0000858306884765625, "scale" : 36071.483527679447},
			            {"level" : 15, "resolution" : 0.0000429153442382812, "scale" : 18035.741763839724},
			            {"level" : 16, "resolution" : 0.0000214576721191406, "scale" : 9017.8708819198619},
			            {"level" : 17, "resolution" : 0.0000107288360595703, "scale" : 4508.9354409599309},
			            {"level" : 18, "resolution" : 5.36441802978515E-06, "scale" : 2254.4677204799655}
		            ],
		            zoom:8,
		            iniExtent:null, // 初始范围
		            maxZoom:18,
		            minZoom:0,
		            logo:false,
		            slider:true,
		            dlwkid:4326,
		            tywkid:102100,
		            mapisdlwkid:true,
		            sliderPosition: 'bottom-right'//放大缩小按钮位置,"top-left", "top-right", "bottom-left", "bottom-right"
				};

				para = jQuery.extend(false, defaultPara, para);
				var go = $rootScope.gisObject;

		        arcGISObject.initFinshEvent= function(){
			        // 设置当前地图坐标系
			        go.dlwkid = new esri.SpatialReference(para.dlwkid);
					go.tywkid = new esri.SpatialReference(para.tywkid);
					go.mapisdlwkid = para.mapisdlwkid;
			        if(go.mapisdlwkid==true){
			        	go.mapwkid = go.dlwkid;
			        }else{
			        	go.mapwkid = go.tywkid;
			        }
			        var extent = new esri.geometry.Extent({
						"xmin" : para.iniExtent[0],
						"ymin" : para.iniExtent[1],
						"xmax" : para.iniExtent[2],
						"ymax" : para.iniExtent[3],
						"spatialReference" : go.mapwkid
					});
					go.fullExtent = extent;

		        	// 初始化地图
					go.map = new esri.Map(attrs.id, {
						extent : extent,
						sliderStyle : para.sliderStyle,
						lods : para.lods,
						zoom : para.zoom,
						maxZoom : para.maxZoom,
						minZoom : para.minZoom,
						logo : para.logo,
						slider : para.slider,
						sliderPosition: para.sliderPosition
					});
			        window.map = go.map;
			        
			  		// 添加比例尺
					var scalebar = new esri.dijit.Scalebar({  
						map: go.map, // 必须的  
						scalebarUnit: "metric"  // 指定比例尺单位,有效值是"english" or "metric".默认"english"  
					}); 

					// 添加当前mouse坐标
					go.map.on("mouse-move", function(e){
						scope.$apply(function() {
							if(e.mapPoint.x && e.mapPoint.y){
								go.mapPointX = e.mapPoint.x.toFixed(4);
								go.mapPointY = e.mapPoint.y.toFixed(4);
							}
						});
					});

					// 初始化基础信息
					$rootScope.initMapBase();

					var onFinshed = null;
					if(attrs.onfinshed){
						onFinshed = $rootScope[attrs.onfinshed];
						if(onFinshed){
							onFinshed();
						}
					}
		        }
			}
		};
	}]);
}(window, angular));
(function(window, angular, undefined){
	angular.module('arcgis.map', ['arcgis.map.base','arcgis.map.layer','arcgis.map.ui']);
}(window, angular));
(function(window, angular, undefined){
	angular.module('arcgis.search.attribute', [])
	.factory('$arcgis_search_attribute', ["$rootScope", function($rootScope) {
		$arcgis_search_attribute = {
			/**
			 * 初始化属性查询
			 * 如果存在数据之前的查询数据，则保留数据
			 */
			initAttSearch : function(sn, para){
				var defulatPara = {
					// 属性查询是否在当前的视图范围内
					extent : null,
					// 属性查询的属性参数
					attribute : {},
					// 字段是否为中文
					fieldUseZh:false
				};
				para = para ? para : {};
				var temp = jQuery.extend(false, $rootScope.getDefultPara(), defulatPara);
				$rootScope.gisObject[sn] = jQuery.extend(false, temp, para);
				var sp = $rootScope.gisObject[sn];
				if(!sp.url.startWith('http://')){
					sp.url = getGisBaseUrl()+sp.url;
				}
				$rootScope.deDrawAndClearGraphics();
			},
			
			/**
			 * 属性查询
			 */
		    attSearch : function(sn,onResult){
				$rootScope.deDrawAndClearGraphics();
				var sp = $rootScope.gisObject[sn];

				var whereString = $rootScope.getWhereString(sp);
				if(!whereString || whereString==""){
					alert("请输入有效的查询条件！");
					return false;
				}
	          	// 实例化QueryTask，查询图层2，也就是States图层
	          	queryTask = new esri.tasks.QueryTask(sp.url);
	          	// 查询参数
	          	query = new esri.tasks.Query();
				// 需要返回的字段 ["*"]
	          	query.outFields = sp.selectFields;
	          	// 当前视图范围
	          	if(sp.extent && (sp.extent == "true" || sp.extent == true)){
					// 空间查询
		          	query.geometry = $rootScope.gisObject.map.extent;
					query.outSpatialReference = $rootScope.gisObject.mapwkid;
					query.inSpatialReference = query.outSpatialReference;
					query.spatialRelationship = esri.tasks.Query.SPATIAL_REL_CONTAINS;
	          	}
	          	//需要返回Geometry
	          	query.returnGeometry = true;
	          	//查询条件
	          	query.where = whereString;
	          	
	          	//进行查询
	          	onResult = onResult ? onResult : $rootScope.simpleSearchResult;
	          	queryTask.execute(query, function(results){
	          		onResult(sn, results);
	          	});
	          	return true;
		    },

		    /**
			 * 获取属性查询条件
			 */
		    getWhereString : function(sp){
		    	var fieldUseZh = sp.fieldUseZh == true ? true : false;
		    	var attribute = sp.attribute;
		    	if(!attribute) return "";

				var whereString = "";
	    		for(key in attribute){ 
					var fields = key.split(":");
					var field = null;
					var option = null;
					if (fields.length == 2) {
						field = fields[0];
						option = fields[1];
					} else {
						field = key;
						option = "=";
					}
					if(fieldUseZh){
						field = "'"+field+"'";
					}
					var value = attribute[key];

					if(value!=""){
						if (option=="=") {
							if (value==("\"null\"")) {
								whereString += field + " is null and ";
							} else {
								if(typeof value == "string"){
									whereString += field + " = '"+value+"' and ";
								}
								else{
									whereString += field + " = "+value+" and ";
								}
							}
						} else if (option==">") {
							whereString += field + " > "+value+" and ";
						} else if (option=="!=") {
							whereString += field + " != '"+value+"' and ";
						} else if (option==">=") {
							whereString += field + " >= "+value+" and ";
						} else if (option=="<") {
							whereString += field + " < "+value+" and ";
						} else if (option=="<=") {
							whereString += field + " <= "+value+" and ";
						} else if (option=="in") {
							whereString += field + " in (" + value.toString() + ") and ";
						} else if (option=="nin") {
							whereString += field + " not in (" + value.toString() + ") and ";
						} else if (option=="isnull") {
							whereString += field + " is null and ";
						} else if (option=="isnnull") {
							whereString += field + " is not null and ";
						} else if (option=="like") {
							whereString += field + " like '%" + value.toString() + "%' and ";
						} else if (option=="%like") { 
							whereString += field + " like '%" + value.toString() + "' and ";
						} else if (option=="like%") { 
							whereString += field + " like '" + value.toString() + "%' and ";
						}
					}
				}
				if(whereString!=""){
					whereString = whereString.substring(0, whereString.length-4);
				}
				return whereString;
		    }
		};
		for(f in $arcgis_search_attribute){
			$rootScope[f] = $arcgis_search_attribute[f];
		}
		return $arcgis_search_attribute;
	}])
	.run(["$rootScope", "$arcgis_search_attribute", function($rootScope, $arcgis_search_attribute) { }]);
}(window, angular));
(function(window, angular, undefined){
	angular.module('arcgis.search.find', [])
	.factory('$arcgis_search_find', ["$rootScope", function($rootScope) {
		$arcgis_search_find = {

			/**
			 * 初始化键字查询
			 * 如果存在数据之前的查询数据，则保留数据
			 */
			initFindSearch : function(sn, para){
				var defulatPara = {
					// findtask的查询值
					searchText : '',
					// identify查询和find查询的图层IDs
					searchLayerIds : null,
					// identify查询和find查询的子查询名称
					searchNames : null,
					// 有结果的图层
					resultLayers: null
				};
				para = para ? para : {};
				var temp = jQuery.extend(false, $rootScope.getDefultPara(), defulatPara);
				$rootScope.gisObject[sn] = jQuery.extend(false, temp, para);
				var sp = $rootScope.gisObject[sn];
				if(!sp.url.startWith('http://')){
					sp.url = getGisBaseUrl()+sp.url;
				}
				$rootScope.deDrawAndClearGraphics();
			},

			/**
			 * find属性查询
			 */
			findSearch : function(sn, onResult){
				$rootScope.deDrawAndClearGraphics();
				var sp = $rootScope.gisObject[sn];
				var whereString = sp.searchText;
				if(!whereString || whereString==""){
					alert("请输入有效的查询条件！");
					return false;
				}

				//实例化FindTask
				findTask = new esri.tasks.FindTask(sp.url);
				//FindTask的参数
				findParams = new esri.tasks.FindParameters();
				//返回Geometry
				findParams.returnGeometry = true;
				//查询的图层id
				findParams.layerIds = sp.searchLayerIds;
				//查询字段
				findParams.searchFields = sp.selectFields;
				findParams.searchText = whereString;

				onResult = onResult ? onResult : $rootScope.mutliSearchResult;
				findTask.execute(findParams, function(results){
	          		onResult(sn, results);
	          	});
	          	return true;
			}
		};
		for(f in $arcgis_search_find){
			$rootScope[f] = $arcgis_search_find[f];
		}
		return $arcgis_search_find;
	}])
	.run(["$rootScope", "$arcgis_search_find", function($rootScope, $arcgis_search_find) { }]);
}(window, angular));
(function(window, angular, undefined){
	angular.module('arcgis.search.identify', [])
	.factory('$arcgis_search_identify', ["$rootScope", function($rootScope) {
		$arcgis_search_identify = {

			/**
			 * 初始化identify空间查询
			 * 如果存在数据之前的查询数据，则保留数据
			 */
			initIdentifySearch : function(sn, para){
				var defulatPara = {
					// identify查询和find查询的图层IDs
					searchLayerIds : null,
					// 有结果的图层
					resultLayers:null,
					// 空间查询缓存，单位米
					buffer : null
				};
				para = para ? para : {};
				var temp = jQuery.extend(false, $rootScope.getDefultPara(), defulatPara);
				$rootScope.gisObject[sn] = jQuery.extend(false, temp, para);
				var sp = $rootScope.gisObject[sn];
				if(!sp.url.startWith('http://')){
					sp.url = getGisBaseUrl()+sp.url;
				}
				$rootScope.deDrawAndClearGraphics();
			},

			/**
			 * identify空间查询
			 */
			identifySearch : function(sn, onResult){
				$rootScope.deDrawAndClearGraphics();
				var distances = $rootScope.needBuffer(sn);

				$rootScope.drawPoint(function(geometry){
					$rootScope.deDrawAndClearGraphics();
					/*$rootScope.getBufferGeometry([geometry],distances,function(geoResult){
						$rootScope.innerIdentifySearch(sn, geoResult[0], onResult);
					});*/
					$rootScope.innerIdentifySearch(sn, geometry, onResult);
				});
				return true;
			},

			/**
			 * 内部Identify查询
			 */
		    innerIdentifySearch : function(sn, geometry, onResult){
		    	// 临时显示缓冲区
				$rootScope.addGraphic(geometry);
				var sp = $rootScope.gisObject[sn];
		    	//实例化IdentifyTask
		       	identifyTask = new esri.tasks.IdentifyTask(sp.url);
		       	// IdentifyTask参数设置
		       	identifyParams = new esri.tasks.IdentifyParameters();
		       	// 冗余范围
		       	identifyParams.tolerance = 3;
		       	// 返回地理元素
		       	identifyParams.returnGeometry = true;
                // 返回非格式化值，arcgis 10.5以后支持
                identifyParams.returnUnformattedValues = true;
		       	// 进行Identify的图层
		       	identifyParams.layerIds = sp.searchLayerIds;
		       	// 进行Identify的图层为全部
		       	identifyParams.layerOption = esri.tasks.IdentifyParameters.LAYER_OPTION_ALL;
		       	// Identify的geometry
		       	identifyParams.geometry = geometry;
		       	// Identify范围
		       	identifyParams.mapExtent = $rootScope.gisObject.map.extent;

		       	onResult = onResult ? onResult : $rootScope.mutliSearchResult;
		       	identifyTask.execute(identifyParams, function(results){
	          		onResult(sn, results);
	          	});
		    }
		};
		for(f in $arcgis_search_identify){
			$rootScope[f] = $arcgis_search_identify[f];
		}
		return $arcgis_search_identify;
	}])
	.run(["$rootScope", "$arcgis_search_identify", function($rootScope, $arcgis_search_identify) { }]);
}(window, angular));
(function(window, angular, undefined){
	angular.module('arcgis.search.result.mutli', [])
	.factory('$arcgis_search_result_mutli', ["$rootScope", function($rootScope) {
		$arcgis_search_result_mutli = {

			/**
			 * 显示多查询结果
			 */
		    mutliSearchResult : function(sn, results){
		    	//清除上一次的高亮显示
		       	$rootScope.deDrawAndClearGraphics();
		       	if(!results || results.length<=0){
		       		results = [];
		       	}

		       	$rootScope.clearSearchResultEx(sn);
		       	var fln = '';

		       	for(var i=0;i<results.length;i++){
		       		var row = results[i].feature;
		       		var clsn = sn + "_" + results[i].layerId;
		       		if(fln=='') fln = clsn;
		       		$rootScope.gisObject[clsn].resultList.push(row);
		       	}

		       	var sp = $rootScope.gisObject[sn];
		       	// 初始化查询结果
		       	$rootScope.$apply(function() {
		       		sp.searchNames.forEach(function(e){
			       		$rootScope.initSearchPages($rootScope.gisObject[e]);
			       	});
		       	});
		       	
		       	// 初始化查询结果
		       	$rootScope.$apply(function() {
		       		$rootScope.setGisPageIndex(fln, 1);
		       		// 这里因交互问题，暂时写死规则
		       		$rootScope.setTab(sn, fln);
		       	});
		    },

		    /**
			 * 清除查询结果，并返回查询页面
			 */
		    clearSearchResultEx : function(sn){
		    	$rootScope.deDrawAndClearGraphics();
		    	var sp = $rootScope.gisObject[sn];
		    	if(!sp) return;
		       	sp.resultLayers = [];
		       	sp.searchNames.forEach(function(e){
		       		var csp = $rootScope.gisObject[e];
		       		csp.resultList = [];
					csp.pageList = [];
					csp.rowCount = 0;
					csp.pageCount = 0;
					csp.pageIndex = 1;
		       	});
		    }
		};
		for(f in $arcgis_search_result_mutli){
			$rootScope[f] = $arcgis_search_result_mutli[f];
		}
		return $arcgis_search_result_mutli;
	}])
	.run(["$rootScope", "$arcgis_search_result_mutli", function($rootScope, $arcgis_search_result_mutli) { }]);
}(window, angular));
(function(window, angular, undefined){
	angular.module('arcgis.search.result.simple', [])
	.factory('$arcgis_search_result_simple', ["$rootScope", function($rootScope) {
		$arcgis_search_result_simple = {

			/**
			 * 定义简单查询果处理入口
			 */
			simpleSearchResult : function(sn,results){
		       	//清除上一次的高亮显示
		       	$rootScope.deDrawAndClearGraphics();
		       	if(!results || results.features.length<=0){
		       		results = {};
		       		results.features = [];
		       	}

		       	var sp = $rootScope.gisObject[sn];
		       	sp.resultList = results.features;

		    	$rootScope.initSearchPages(sp);
								
				// 初始化查询结果
		       	$rootScope.$apply(function() {
		       		$rootScope.setGisPageIndex(sn, 1);
		       	});
		    },

		    initSearchPages : function(sp){
				var rowCount = sp.resultList.length;
				if(rowCount<0){
					rowCount = 0;
				}
				var pageSize = sp.pageSize;
				var pCount = rowCount / pageSize;
				pCount = parseInt(pCount);
				if((pageSize*pCount) < rowCount){
					pCount++;
				}
				// 查询的总页数
				sp.pageCount = pCount;
				sp.rowCount = rowCount;
		    },

			/**
			 * 上一页
			 */
			preGisPage : function(sn){
				var pageIndex = $rootScope.gisObject[sn].pageIndex;
				pageIndex--;
				if(pageIndex<=0){
					pageIndex =1 ;
				}
				$rootScope.setGisPageIndex(sn, pageIndex);
			},
			
			/**
			 * 下一页
			 */
			nextGisPage : function(sn){
				var sp = $rootScope.gisObject[sn];
				var pageIndex = sp.pageIndex;
				var pageCount = sp.pageCount;
				pageIndex++;
				if(pageIndex>pageCount){
					pageIndex = pageCount ;
				}
				$rootScope.setGisPageIndex(sn, pageIndex);
			},
			
			/**
			 * 首页
			 */
			firstGisPage : function(sn){
				$rootScope.setGisPageIndex(sn, 1);
			},
			
			/**
			 * 尾页
			 */
			lastGisPage : function(sn){
				var pageCount = $rootScope.gisObject[sn].pageCount;
				$rootScope.setGisPageIndex(sn, pageCount);
			},

			/**
			 * 设置分页索引并且重新计算数据
			 */
			setGisPageIndex : function(sn, pageIndex){
				var sp = $rootScope.gisObject[sn];
				// 设置查询信息模板
	          	$rootScope.setSearchInfo(sp);
	          	
				sp.pageIndex = pageIndex;
				
				if(sp.rowCount<=0){
					sp.pageList = [];
					return;
				}

				var pageSize = sp.pageSize;
				var endIndex = pageIndex * pageSize;
				var beginIndex = endIndex - pageSize;

				if(beginIndex > sp.rowCount -1){
					return;
				}

				if(endIndex>sp.rowCount){
					endIndex=sp.rowCount;
				}

				var pageList=[];

				for(var i=beginIndex;i<endIndex;i++){
					pageList.push(sp.resultList[i]);
				}
				
				var mustConvert=false;

				var attrs=[];
				var index=[];
				for(var k=0;k<pageList.length;k++){
					var attr=pageList[k].attributes;
					if(attr.havedomian==null 
						|| attr.havedomian==''
						|| attr.havedomian=='undefined'){
						mustConvert=true;
						attrs.push(attr);
						index.push(k);
					}
				}

				if(sp.medname!=null && pageList!=null && pageList.length>0 && mustConvert){
					$rootScope.datadomainConvert(attrs,
						sp.medname,
						sp.medroot,mustConvert,function(data){
						$rootScope.$apply(function(){
							if(data!=null){
								for(var k=0;k<data.length;k++){
									data[k].havedomian=true;
									pageList[index[k]].attributes=data[k];
								}
								sp.pageList=pageList;
								$rootScope.showPageResults(sp);
							}
						});
						
					});

				}else{
					sp.pageList=pageList;
					$rootScope.showPageResults(sp);
				}
			},		
		    
		    /**
			 * 页面显示
			 */
		    showPageResults : function(sp){
		    	// 清除结果
		    	$rootScope.deDrawAndClearGraphics();
		    	var pageList = sp.pageList;
		    	
		    	// 如果数据量太大，先做simple
		       	if(sp.simple == true && pageList.length>1000){
		       		pageList = $rootScope.simple(pageList);
		       	}
		       	
		       	// 各参数
		       	var showFeature = sp.showFeature;
	          	var infoTemplate = null;
	          	if(sp.showWindows == true){
					infoTemplate = sp.infoTemplate;
				}

		       	for (var i=0;i<pageList.length; i++){
		          	var feature = pageList[i];
			       	feature.geometry.spatialReference = $rootScope.gisObject.mapwkid;
					if(!feature.attributes){
						feature.attributes = {};
					}
					if(!feature.attributes._guid){
						feature.attributes._guid = $rootScope.getGUID();
					}
                    for(var i in feature.attributes) {
						if(feature.attributes[i]==='Null'){
                            feature.attributes[i] = '';
						}
                    }

					// 设置要素选中
		          	if(showFeature){
		          		$rootScope.addFeatureSelectGraphic(feature, infoTemplate);
		          	}
		       	}

		       	// 启用map.graphics的鼠标事件
			    $rootScope.gisObject.map.graphics.enableMouseEvents();
			    dojo.disconnect(sp.mouseOverHandle);
			    dojo.disconnect(sp.mouseOutHandle);
			    dojo.disconnect(sp.clickHandle);

			    sp.mouseOverHandle = dojo.connect($rootScope.gisObject.map.graphics, "onMouseOver", function (evt){
			    	var graphic = evt.graphic;
			    	if(!graphic.attributes){
			    		return;
			    	}
			    	$rootScope.gisObject.map.setMapCursor("pointer");
			    	if(graphic.attributes.$isFeature && graphic.attributes.$isFeature==true){
			    		$rootScope.highFeatureSelectGraphicEx(graphic);
			    	}
			    });
			    sp.mouseOutHandle = dojo.connect($rootScope.gisObject.map.graphics, "onMouseOut", function (evt){
			       	var graphic = evt.graphic;
			    	if(!graphic.attributes){
			    		return;
			    	}
			    	$rootScope.gisObject.map.setMapCursor("default");
			    	if(graphic.attributes.$isFeature && graphic.attributes.$isFeature==true){
			    		$rootScope.featureSelectGraphicEx(graphic);
			    	}
			    });
		       	sp.clickHandle = dojo.connect($rootScope.gisObject.map.graphics, "onClick", function (evt){
		    		var graphic = evt.graphic;
		    		if(!graphic.attributes){
			    		return;
			    	}
		    		if(graphic.attributes.$isFeature && graphic.attributes.$isFeature==true){
			    		$rootScope.showInfoWindowEx(graphic);
			    	}
		    	});

		    	//设置地图视图范围
				var rExtent = $rootScope.getMaxExtent(pageList);
				$rootScope.gisObject.map.setExtent(rExtent);

				// 显示第一个节点
	       		$rootScope.showInfoWindow(pageList[0].attributes._guid);
		    },

		    /**
			 * 清除查询结果，并返回查询页面
			 */
		    clearSearchResult : function(sn){
		    	$rootScope.deDrawAndClearGraphics();
		    	var sp = $rootScope.gisObject[sn];
		       	sp.resultList = [];
				sp.pageList = [];
				sp.rowCount = 0;
				sp.pageCount = 0;
				sp.pageIndex = 1;
		    }
		};
		for(f in $arcgis_search_result_simple){
			$rootScope[f] = $arcgis_search_result_simple[f];
		}
		return $arcgis_search_result_simple;
	}])
	.run(["$rootScope", "$arcgis_search_result_simple", function($rootScope, $arcgis_search_result_simple) { }]);
}(window, angular));
(function(window, angular, undefined){
	angular.module('arcgis.search.space', [])
	.factory('$arcgis_search_space', ["$rootScope", function($rootScope) {
		$arcgis_search_space = {

			/**
			 * 初始化空间查询
			 * 如果存在数据之前的查询数据，则保留数据
			 */
			initSpaceSearch : function(sn, para){
				var defulatPara = {
					// 空间查询类型 polygon, line, point
					type : 'polygon',
					// 空间查询缓存，单位米
					buffer : null
				};
				para = para ? para : {};
				var temp = jQuery.extend(false, $rootScope.getDefultPara(), defulatPara);
				$rootScope.gisObject[sn] = jQuery.extend(false, temp, para);
				var sp = $rootScope.gisObject[sn];
				if(!sp.url.startWith('http://')){
					sp.url = getGisBaseUrl()+sp.url;
				}
				$rootScope.deDrawAndClearGraphics();
			},

			/**
			 * 设置类型值
			 */
			setSpaceSearchType : function(sn, type){
		    	$rootScope.gisObject[sn].type = type;
		    },

		    /**
			 * 设置buffer值
			 */
		    setSpaceSearchBuffer : function(sn, buffer){
		    	$rootScope.gisObject[sn].buffer = buffer;
		    },

		    /**
			 * 空间查询
			 */
			spaceSearch : function(sn, onResult){
				var type = $rootScope.gisObject[sn].type;
				if(!type){
					alert("请指定空间查询类型！");
					return false
				}

				$rootScope.deDrawAndClearGraphics();
				var distances = $rootScope.needBuffer(sn);

				if(type=="point"){
					$rootScope.drawPoint(function(geometry){
						$rootScope.deDrawAndClearGraphics();
						$rootScope.getBufferGeometry([geometry],distances,function(geoResult){
							$rootScope.innerSpaceSearch(sn, geoResult[0], onResult);
						});
					});
					return true;
				}
				if(type=="line"){
					$rootScope.drawPolyline(function(geometry){
						$rootScope.deDrawAndClearGraphics();
						$rootScope.getBufferGeometry([geometry],distances,function(geoResult){
							$rootScope.innerSpaceSearch(sn, geoResult[0], onResult);
						});
					});
					return true;
				}
				if(type=="polygon"){
					$rootScope.drawPolygon(function(geometry){
						$rootScope.deDrawAndClearGraphics();
						$rootScope.getBufferGeometry([geometry],distances,function(geoResult){
							$rootScope.innerSpaceSearch(sn, geoResult[0], onResult);
						});
					});
					return true;
				}
			},

			/**
			 * 内部空间查询
			 */
		    innerSpaceSearch : function(sn, geometry, onResult){
		    	// 临时显示缓冲区
				$rootScope.addGraphic(geometry);

		    	var sp = $rootScope.gisObject[sn];
		    	// 实例化QueryTask，查询图层2，也就是States图层
	          	queryTask = new esri.tasks.QueryTask(sp.url);
	          	// 查询参数
	          	query = new esri.tasks.Query();
				// 需要返回的字段 ["*"]
	          	query.outFields = sp.selectFields;
	          	//需要返回Geometry
	          	query.returnGeometry = true;
	          	// 处理空间查询
	          	query.geometry = geometry;
				query.outSpatialReference = $rootScope.gisObject.mapwkid;
				// SPATIAL_REL_CONTAINS 包含，SPATIAL_REL_INTERSECTS 相交
				query.spatialRelationship = esri.tasks.Query.SPATIAL_REL_INTERSECTS; 

	          	//进行查询
	          	onResult = onResult ? onResult : $rootScope.simpleSearchResult;
	          	queryTask.execute(query, function(results){
	          		onResult(sn, results);
	          	});
		    }
		};
		for(f in $arcgis_search_space){
			$rootScope[f] = $arcgis_search_space[f];
		}
		return $arcgis_search_space;
	}])
	.run(["$rootScope", "$arcgis_search_space", function($rootScope, $arcgis_search_space) { }]);
}(window, angular));
(function(window, angular, undefined){
	angular.module('arcgis.search.utils', [])
	.factory('$arcgis_search_utils', ["$rootScope", function($rootScope) {
		$arcgis_search_utils = {

			/**
			 * 初始化查询
			 */
			initBaseSearch : function(sn, para){
				$rootScope.gisObject[sn] = jQuery.extend(false, $rootScope.getDefultPara(), para);
			},

			/**
			 * 获取通用查询参数
			 */
			getDefultPara : function(){
				var defulatPara = {
					// 查询的服务
					url : null,
					// 查询的字段
					selectFields :['*'],
					// 是否高亮显示要素
					showFeature : true,
					// 是否显示小弹窗
					showWindows : true,
					// 查询展示样式的标题
					infoTemplateTitle : '',
					// 查询展示样式的内容
					infoTemplateContent : '',
					// 查询展示样式
					infoTemplate : null,
					// 查询展示窗口的宽
					infoWindowWidth : 240,
					// 查询展示窗口的高
					infoWindowHeiht : 120,
					// 查询的分页大小
					pageSize : 5,
					// 查询的分页大小
					pageIndex : 1,
					// 查询的总页数
					pageCount : 0,
					// 查询的总记录数
					rowCount : 0,
					// 查询结果列表
					resultList : null,
					// 查询的当前页列表
					pageList : null,
					// 是否对查询值做抽稀处理
					simple : false
				};
				return defulatPara;
			},

			/**
			 * 设置查询信息模板
			 */
			setSearchInfo : function(sp){
				if(!sp) return;
				//信息模板
	          	sp.infoTemplate = new esri.InfoTemplate();
	          	//设置Title
	          	var title = sp.infoTemplateTitle;
	          	title = title.replace(/~/gm,'$');
	          	sp.infoTemplate.setTitle(title);
	          	//设置Content
	          	var contentId = sp.infoTemplateContent;
	          	var content = '';
	          	if(contentId && contentId!=''){
	          		var element = $('#'+contentId);
		          	if(element && element.length>0){
		          		content = element[0].innerHTML;
		          	}
	          	}
	          	if(content == null || content == ""){
	          		content = '<b>OBJECTID: </b>~{OBJECTID}';
	          	}
	          	content = content.replace(/~/gm,'$');
	          	sp.infoTemplate.setContent(content);
	          	//设置infoWindow的尺寸
	          	$rootScope.gisObject.map.infoWindow.resize(sp.infoWindowWidth, sp.infoWindowHeiht);
	        },

	        /**
	         * 是否需要做buffer
	         */
	        needBuffer : function(sn){
	        	var buffer = $rootScope.gisObject[sn].buffer;
				if(buffer && buffer!="" && buffer!="0"){
					// 先做buffer
					return parseInt(buffer);
				}else{
					return -1;
				}
	        },

	        /**
			 * 依据数据进行数据字典转换
			 * @param  {[type]} list       [description]
			 * @param  {[type]} medname    [description]
			 * @param  {[type]} rooturl    [description]
			 * @param  {[type]} oncomplete [description]
			 * @return {[type]}            [description]
			 */
			datadomainConvert:function(list,medname,rooturl,mustConvert,oncomplete,error){
				if(mustConvert==null){
					mustConvert=false;
				}

				if(mustConvert){
					if(rooturl==null){
						rooturl=getServerBaseUrl();
					}
					var url=rooturl+"/metadata/dictionaryEscapeEx";
					var args={};
					args.id=medname;
					args.values=$rootScope.toJSONStr(list);
					args=$rootScope.toJSONStr(args);
					jQuery.support.cors = true;
					$.ajax({
						url : url,
						type : 'POST',
						data : args,
						timeout : 35000,
						headers: { 'jwt': $.cookie('jwt') },
						contentType: "application/json;charset=utf-8", 
						dataType : 'json',
						success : function(data){
							if(oncomplete){
								oncomplete(data);
							}
						},
						error : function(e){
							if(error){
								error(e);
							}
						}
					});
				}else{
					if(oncomplete){
						oncomplete(list);
					}
				}
			}
		};
		for(f in $arcgis_search_utils){
			$rootScope[f] = $arcgis_search_utils[f];
		}
		return $arcgis_search_utils;
	}])
	.run(["$rootScope", "$arcgis_search_utils", function($rootScope, $arcgis_search_utils) {
	}]);
}(window, angular));
(function(window, angular, undefined){
	angular.module('arcgis.search', ['arcgis.search.attribute','arcgis.search.find','arcgis.search.identify','arcgis.search.result.mutli','arcgis.search.result.simple','arcgis.search.space','arcgis.search.utils']);
}(window, angular));
(function(window, angular, undefined){
	angular.module('arcgis.ui.page',[])
	.directive('agGisPage', ["$rootScope", "$compile", function($rootScope,$compile) {
	    return {
	        replace: true,
	        restrict: 'E',
	        require: "",
	        link: function(scope, element, attrs, ctrl) {
	        	var fn = attrs.fn;
	        	var pageHtml = 	'    <p class="total">'+
								'        共<label ng-bind="gisObject.'+fn+'.rowCount"></label>条结果'+
								'        - <label ng-bind="gisObject.'+fn+'.pageIndex"></label>/<label ng-bind="gisObject.'+fn+'.pageCount"></label>页'+
								'    </p>'+
								'    <div class="pager">'+
								'        <i title="上一页" class="prev opa" ng-click="preGisPage(\''+fn+'\')">'+
								'        </i>'+
								'        <i title="下一页" class="next opa" ng-click="nextGisPage(\''+fn+'\')">'+
								'        </i>'+
								'    </div>';
				
				var el = document.createElement("div");
		       	el.innerHTML = pageHtml;
		       	$compile($(el))(scope);
		       	var pageUl=el.firstChild;
		       	element.html(el);
	        }
	    };
	}]);
}(window, angular));
(function(window, angular, undefined){
	angular.module('arcgis.ui', ['arcgis.ui.page']);
}(window, angular));
(function(window, angular, undefined){
	angular.module('gis.arcgis', ['arcgis.base','arcgis.locator','arcgis.map','arcgis.search','arcgis.ui']);
}(window, angular));